//
//  CrazyChatOrderListCell.m
//  webSocket
//
//  Created by 马军凯 on 2019/2/20.
//  Copyright © 2019年 ZH. All rights reserved.
//

#import "CrazyChatOrderListCell.h"

@interface CrazyChatOrderListCell ()

@property (nonatomic, strong) UIImageView *picImageView; //图片
@property (nonatomic, strong) UILabel *titleLabel; //标题
@property (nonatomic, strong) UILabel *attrLabel; //属性
@property (nonatomic, strong) UILabel *priceLabel; //价格
@property (nonatomic, strong) UILabel *numLabel; //数量

@end

@implementation CrazyChatOrderListCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        //图片
        self.picImageView = [[UIImageView alloc] init];
        self.picImageView.frame = CGRectMake(10, 20, 60, 60);
        [self.contentView addSubview:self.picImageView];
        //标题
        self.titleLabel = [[UILabel alloc] init];
        self.titleLabel.frame = CGRectMake(80, 20, CRAZY_SCREEN_WIDTH - 90, 20);
        self.titleLabel.numberOfLines = 2;
        self.titleLabel.textColor = CRAZY_RGBR(33);
        self.titleLabel.font = [UIFont systemFontOfSize:14];
        [self.contentView addSubview:self.titleLabel];
        //价格
        self.priceLabel = [[UILabel alloc] init];
        self.priceLabel.textColor = CRAZY_RGBR(0);
        self.priceLabel.font = [UIFont boldSystemFontOfSize:14];
        [self.contentView addSubview:self.priceLabel];
        [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(80);
            make.bottom.equalTo(self.picImageView.mas_bottom);
            make.width.mas_equalTo(CRAZY_SCREEN_WIDTH - 140);
        }];
        //数量
        self.numLabel = [[UILabel alloc] init];
        self.numLabel.textColor = CRAZY_RGBR(110);
        self.numLabel.font = [UIFont systemFontOfSize:14];
        self.numLabel.textAlignment = NSTextAlignmentRight;
        [self.contentView addSubview:self.numLabel];
        [self.numLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_offset(CRAZY_SCREEN_WIDTH - 50);
            make.bottom.equalTo(self.priceLabel.mas_bottom);
            make.width.mas_offset(40);
        }];
        //属性
        self.attrLabel = [[UILabel alloc] init];
        self.attrLabel.textColor = CRAZY_RGBR(110);
        self.attrLabel.font = [UIFont systemFontOfSize:12];
        [self.contentView addSubview:self.attrLabel];
        [self.attrLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_offset(80);
            make.bottom.equalTo(self.priceLabel.mas_top).offset(-8);
            make.width.mas_offset(CRAZY_SCREEN_WIDTH - 90);
        }];
    }
    return self;
}






//赋值
- (void)setModel:(CrazyChatOrderListGoodsModel *)model {
    _model = model;
    //图片
    [self.picImageView sd_setImageWithURL:[NSURL URLWithString:model.file] placeholderImage:CRAZY_DEFAULT_LOADIMAGE];
    //标题
    self.titleLabel.text = model.goods_name;
    CGSize size = [self.titleLabel sizeThatFits:CGSizeMake(CRAZY_SCREEN_WIDTH - 90, 40)];
    self.titleLabel.height = size.height;
    //属性
    self.attrLabel.text = @"属性";
    //价格
    self.priceLabel.text = [NSString stringWithFormat:@"%@%@", @"¥", model.single_price];
    //数量
    self.numLabel.text = [NSString stringWithFormat:@"%@%@", @"x", model.quantity];
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
